<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">
<div class="w2">系統管理 » 用戶管理 » 新增用戶</div>
<form:form modelAttribute="usersForm" id="usersForm" action="${appPath}/users/save.htm" method="post">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="80" align="right"><span class='required'>＊</span>姓名：</td>
			<td style="padding:5px;"><form:input style="width:100px" id="name" path="name" required="true" class="easyui-validatebox"/></td>
	    </tr>
		<tr>
			<td width="80" align="right"><span class='required'>＊</span>帳號：</td>
			<td style="padding:5px;"><form:input style="width:100px" id="userName" path="userName" required="true" class="easyui-validatebox" /></td>
	    </tr>
	    <tr>
			<td width="80" align="right"><span class='required'>＊</span>密碼：</td>
			<td style="padding:5px;"><form:password style="width:100px" maxlength="20" id="password" path="password" required="true" class="easyui-validatebox"/></td>
	    </tr>
	    <tr>
			<td width="80" align="right">角色：</td>
			<td style="padding:5px;">
				<form:select path="role" id="role">
					<form:options items="${roleAuth}" itemLabel="authName" itemValue="roleSeq"/>
			   	</form:select>
			</td>
	    </tr>
	    <tr>
			<td width="20%" align="right">狀態：</td>
			<td style="padding:5px;">
				<form:select path="status" id="status">
					<form:option label="關閉" value="0"/>
					<form:option label="開放" value="1"/>
			   	</form:select> 
			</td>
	    </tr>
	    <tr>
			<td colspan="2">
				<a href="#do" class="easyui-linkbutton" onClick="save( $('#usersForm') );">送出</a>
				<a href="${appPath}/users.htm" class="easyui-linkbutton">返回</a>
			</td>
		</tr>
	</table>			
</form:form> 
</div>
<script> 
$.extend($.fn.validatebox.defaults.rules, {
    check: {validator: function(value,param){ var ischeck = false;
    	$.ajax({type: 'POST', async:false, url:"${appPath}/users/checkUserName.htm", data:{userName:value},
    	success: function(data) { ischeck = data; } });
   		return ischeck;
        },message: '帳號重覆!!請確定您是否已經申請過!!'
    }
});
function save( formid ){
	if( formid.form('validate') ){ formid.submit(); }
}
</script>